
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="xms">
    <meta name="author" content="xms">
    <link rel="icon" href="/content/favicon.ico">

    <title>自定义 - 实体 - 按钮 - 新建按钮</title>

    <!-- Bootstrap core CSS -->
    <link href="/content/css/bootstrap3.3.5/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/content/css/dashboard.css" rel="stylesheet">
    <link href="/content/css/font-awesome.min.css" rel="stylesheet">
    <link href="/content/customize/css/common.css" rel="stylesheet">
    <link href="/content/js/jquery-toast/jquery.toast.min.css" rel="stylesheet">
    <link id="themeLink" href="/content/css/theme/default.css" rel="stylesheet" />
    <!-- Bootstrap core JavaScript ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="/content/js/jquery.min.js"></script>
    <script src="/content/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="/content/js/ie10-viewport-bug-workaround.js"></script>
    <script src="/content/js/jquery.bootstrap.min.js"></script>
    <script src="/content/js/json2.js"></script>
    <script src="/content/js/xms.utility.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.core.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.widget.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.mouse.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.draggable.js"></script>
    <script src="/content/js/jquery-toast/jquery.toast.min.js"></script>
    <script src="/content/js/xms.jquery.js"></script>
    <script src="/content/js/xms.web.js"></script>
    <script src="/content/js/xms.metadata.js"></script>
    <script src="/content/js/md5.js" type="text/javascript"></script>
    <script src="/content/js/commonlabels.js"></script>
    <script src="/content/js/common/pagecontext.js"></script>
    <script src="/api/user/usercontext"></script>
    <script>
        jQuery(function () {
            Xms.Web.Loading();
            function aLinkClick(e) {

                if (currentKeycode != 17 && window.parent && window.parent.addToTab) {
                    e.preventDefault();
                    var tabNav = $('#customTabNav', parent.document).children('.iframe-link-linkitem.active');
                    var textEl = tabNav.clone();
                    $(".glyphicon-remove", textEl).remove();
                    var label = textEl.text();
                    textEl = $(this).clone();
                    $("span", textEl).remove();
                    label = label + '-' + textEl.text();
                    var link = $(this).attr("href");
                    var id = $.md5(link);
                    Xms.Web.callParentMethod('addToTab', { id: id, label: label, link: link });
                    return false;
                } else {
                    //  currentKeycode = -99999;
                    //  var link = $(this).attr("href");
                    //  Xms.Web.OpenWindow(link);
                }

            }
            var currentKeycode = -99999;
            $("body").on("click.customizeLinkclick", 'a[href]a:not([href^="javascript:"])a:not([href^="#"])', function (e) {
                aLinkClick.call(this, e);
            });
        });
    </script>
    <style>
    body {
        padding: 0;
        margin: 0;
    }

    .table-responsive {
        max-height: 400px;
        overflow-y: auto;
    }

    .panel-default .panel-heading {
        background-color: white;
    }
</style>
</head>
<body>
<div class="" id="body">
    <div class="clearfix">
        <div class="col-md-12" id="main">
            <div class="" style="padding:5px;" id="renderBody">
                <!--main-->

                <div class="panel panel-default">
                    <div id="collapseTwo" class="panel-collapse collapse in">
                        <div class="panel-body">
                            <form action="/xms/api/ribbonbutton/create" method="post" data-jsonajax="true" data-formdata="false" id="editform" class="form-horizontal" role="form">
                                <input data-val="true" id="EntityId" name="EntityId" type="hidden" />
                                <input id="CommandRules" name="CommandRules" type="hidden" value="" />
                                <input name="showlabel" type="hidden" value="true" />
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label">选择常用按钮</label>
                                    <div class="col-sm-10">
                                        <div class="col-sm-3">
                                            <button class="btn btn-info btn-xs" type="button" onclick="setBtnStyle(this)"><span class="glyphicon glyphicon-plus-sign"></span> 新建</button>
                                            <button class="btn btn-info btn-xs" type="button" onclick="setBtnStyle(this)"><span class="glyphicon glyphicon-floppy-disk"></span> 保存</button>
                                            <button class="btn btn-info btn-xs" type="button" onclick="setBtnStyle(this)"><span class="glyphicon glyphicon-trash"></span> 删除</button>
                                        </div>
                                        <div class="col-sm-3">
                                            <a class="btn btn-default btn-xs" href="javascript:void(0)" onclick="setBtnStyle(this)"><span class="glyphicon glyphicon-edit"></span> 编辑</a>
                                            <a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="setBtnStyle(this)"><span class="glyphicon glyphicon-trash"></span> 删除</a>
                                        </div>
                                        <div class="col-sm-3">
                                            <a class="btn btn-link btn-sm" href="javascript:void(0)" onclick="setBtnStyle(this)"><span class="glyphicon glyphicon-plus-sign"></span> 新建</a>
                                            <a class="btn btn-link btn-sm" href="javascript:void(0)" onclick="setBtnStyle(this)"><span class="glyphicon glyphicon-trash"></span> 删除</a>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="Label">标签</label>
                                    <div class="col-sm-10">
                                        <div class="col-sm-9" style="padding-left: 0px;">
                                        <input class="form-control required" id="Label" name="Label" type="text" />
                                        </div>
                                        <div class="col-sm-3">
                                        <label for="ShowLabel"><input checked="checked" data-val="true" id="ShowLabel" type="checkbox" onclick="$('input[name=showlabel]').val($(this).prop('checked'))" /> 显示标签？</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="Description">标签提示</label>
                                    <div class="col-sm-10">
                        <textarea class="form-control" id="Description" name="Description">
</textarea>
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="CssClass">样式</label>
                                    <div class="col-sm-10">
                                        <input class="form-control" id="CssClass" name="CssClass" type="text" value="" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="Icon">Icon</label>
                                    <div class="col-sm-10">
                                        <input class="form-control" id="Icon" name="Icon" type="text" value="" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="JsLibrary">JS库</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control input-sm lookup hide" name="jslibrary_text" id="jslibrary_text" />
                                        <input type="hidden" name="jslibrary1" id="jslibrary1" />
                                        <select class="form-control" id="jslibrary" name="jslibrary">
                                            <option value=""></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="JsAction">JS方法</label>
                                    <div class="col-sm-10">
                                        <input class="form-control" id="JsAction" name="JsAction" type="text" value="" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="ShowArea">显示区域</label>
                                    <div class="col-sm-10">
                                        <input class="form-control required" data-val="true" data-val-required="The ShowArea field is required." id="ShowArea" name="ShowArea" type="text" value="0" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="ShowArea">显示规则</label>
                                    <div class="col-sm-10">
                                        <button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#ruleModal">
                                            <span class="glyphicon glyphicon-edit"></span> 配置
                                        </button>
                                    </div>
                                </div>
                                <div class="form-group col-sm-12 hide">
                                    <label class="col-sm-2 control-label" for="StateCode1">状态</label>
                                    <div class="col-sm-10">
                                        <label class="checkbox-inline">
                                            <input checked="checked" class="required" data-val="true" data-val-required="required" id="StateCode1" name="StateCode" type="radio" value="true" /> 可用
                                        </label>
                                        <label class="checkbox-inline">
                                            <input class="required" id="StateCode0" name="StateCode" type="radio" value="false" /> 禁用
                                        </label>
                                    </div>
                                </div>
                                <div class="form-group col-sm-12">
                                    <label class="col-sm-2 control-label" for="DisplayOrder">排序</label>
                                    <div class="col-sm-10">
                                        <input class="form-control required" data-val="true" data-val-required="The DisplayOrder field is required." id="DisplayOrder" name="DisplayOrder" type="text" value="0" />
                                    </div>
                                </div>
                                <div class="form-group col-sm-12 text-center" id="form-buttons">
                                    <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-saved"></span> 保存</button>
                                    <button type="reset" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> 重置</button>
                                </div>
                                <!-- （Modal） -->
                                <div class="modal fade" id="ruleModal" tabindex="-1" role="dialog"
                                     aria-labelledby="ruleModalLabel" aria-hidden="true">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal"
                                                        aria-hidden="true">
                                                    ×
                                                </button>
                                                <h4 class="modal-title" id="ruleModalLabel">
                                                    <span class="glyphicon glyphicon-th"></span> 配置按钮显示规则
                                                </h4>
                                            </div>
                                            <div class="modal-body">
                                                <ul id="myTab" class="nav nav-tabs">
                                                    <li class="active">
                                                        <a href="#formstate" data-toggle="tab">
                                                            按表单状态
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="#attributevalue" data-toggle="tab">
                                                            按字段值
                                                        </a>
                                                    </li>
                                                </ul>

                                                <div id="myTabContent" class="tab-content">
                                                    <div class="tab-pane fade in active" id="formstate" style="padding:5px;">
                                                        <div class="row">
                                                            <div class="col-sm-12 form-group">
                                                                <div class="col-sm-4"><label>当表单为勾选的状态时</label></div>
                                                                <div class="col-sm-3">
                                                                    <div class="visible">
                                                                        <label for="formstate_visibled1">显示</label>
                                                                        <input type="radio" name="formstate_visibled" id="formstate_visibled1" value="true" />
                                                                        <label for="formstate_visibled2">隐藏</label>
                                                                        <input type="radio" name="formstate_visibled" id="formstate_visibled2" checked="checked" value="false" />
                                                                    </div>
                                                                </div>
                                                                <div class="col-sm-3">
                                                                    <div class="enable">
                                                                        <label for="formstate_enabled1">可用</label>
                                                                        <input type="radio" name="formstate_enabled" id="formstate_enabled1" value="true" />
                                                                        <label for="formstate_enabled2">禁用</label>
                                                                        <input type="radio" name="formstate_enabled" id="formstate_enabled2" checked="checked" value="false" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div id="formStatusBody">
                                                                <div id="formStatusAddBody" class="col-sm-12 form-group">
                                                                    <div class="col-sm-3"><label><input type="checkbox" name="formstate" value="create" />新建</label></div>
                                                                    <div class="col-sm-3"><label><input type="checkbox" name="formstate" value="update" />编辑</label></div>
                                                                    <div class="col-sm-3"><label><input type="checkbox" name="formstate" value="readonly" />只读</label></div>
                                                                    <div class="col-sm-3"><label><input type="checkbox" name="formstate" value="disabled" />禁用</label></div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="tab-pane fade" id="attributevalue" style="padding:5px;">
                                                        <div class="row" style="max-height:350px;overflow-y:auto;">
                                                            <div class="col-sm-12 form-group">
                                                                <div class="col-sm-4"><label>当字段值等于输入值时</label></div>
                                                                <div class="col-sm-3">
                                                                    <div class="visible">
                                                                        <label for="attributevalue_visibled1">显示</label>
                                                                        <input type="radio" name="attributevalue_visibled" id="attributevalue_visibled1" value="true" />
                                                                        <label for="attributevalue_visibled2">隐藏</label>
                                                                        <input type="radio" name="attributevalue_visibled" id="attributevalue_visibled2" checked="checked" value="false" />
                                                                    </div>
                                                                </div>
                                                                <div class="col-sm-3">
                                                                    <div class="enable">
                                                                        <label for="attributevalue_enabled1">可用</label>
                                                                        <input type="radio" name="attributevalue_enabled" id="attributevalue_enabled1" value="true" />
                                                                        <label for="attributevalue_enabled2">禁用</label>
                                                                        <input type="radio" name="attributevalue_enabled" id="attributevalue_enabled2" checked="checked" value="false" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-12 form-group">
                                                                <div class="btn-group">
                                                                    <button type="button" class="btn btn-primary btn-xs" id="addAttributevalue">
                                                                        <span class="glyphicon glyphicon-plus-sign"></span> 增加
                                                                    </button>
                                                                    <button type="button" class="btn btn-default btn-xs" id="removeAttributevalue">
                                                                        <span class="glyphicon glyphicon-trash"></span> 清空
                                                                    </button>
                                                                </div>
                                                            </div>
                                                            <div id="attributevalueBody">
                                                                <div id="attributevalueOperationBody" class="col-sm-12 col-xs-12 form-group">
                                                                    <div class="col-sm-4 col-xs-4">
                                                                        <select class="form-control" id="attributevalue_select">
                                                                            <option></option>
                                                                        </select>
                                                                    </div>
                                                                    <div class="col-sm-1 col-xs-1">=</div>
                                                                    <div class="col-sm-4 col-xs-4">
                                                                        <input type="text" class="form-control input-sm" id="attributevalue_text1" name="attributevalue_text" placeholder="值" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-default"
                                                        data-dismiss="modal">
                                                    <span class="glyphicon glyphicon-remove"></span> 关闭
                                                </button>
                                                <button type="button" class="btn btn-primary" id="btnFormStatusConfirm" name="returnBtn">
                                                    <span class="glyphicon glyphicon-ok"></span> 确定
                                                </button>
                                            </div>
                                        </div><!-- /.modal-content -->
                                    </div><!-- /.modal-dialog -->
                                </div><!-- /.modal --></form>
                        </div>
                    </div>
                </div>

            </div>
            <nav class="navbar navbar-default navbar-fixed-bottom hide" role="navigation" id="body-footer">
                <div class="container">
                    <div class="navbar-form navbar-right" id="body-footer-content">
                    </div>
                </div>
            </nav>
        </div>
    </div>
</div>

<script src="/content/js/jquery.form.js"></script>
<script src="/content/js/jquery-validate/jquery.validate.min.js"></script>
<script src="/content/js/jquery-validate/localization/messages_zh.min.js"></script>
<script src="/content/js/xms.metadata.js"></script>
<script src="/content/js/common/bsinfos.js"></script>
<script>
    $(function () {
        var model = $.urlParamObj(location.href);
        $('#EntityId').val(model.entityid);
        $('#ShowArea').picklist({
            items: [{ label: '表单', value: '1' }, { label: '列表头部', value: '2' }, { label: '列表行内', value: '3' }, { label: '单据体', value: '4' }]//
            , required: true
            , changeHandler: function (e) {
                if ($(this).val() == 'Form') {
                    $('#visibledRule').removeClass('hide');
                    $('#ruleTab').find('li:first').removeClass('hide').addClass('active').trigger('click');
                    $('#ruleTab').find('li:last').removeClass('hide');
                }
                else if ($(this).val() == 'ListRow') {
                    $('#visibledRule').removeClass('hide');
                    $('#ruleTab').find('li:first').addClass('hide').removeClass('active');
                    $('#ruleTab').find('li:last').removeClass('hide').addClass('active').trigger('click');
                }
                else {
                    $('#visibledRule').addClass('hide');
                }
            }
        });
        //表单验证
        Xms.Web.Form($("#editform"), function (response) {
            Xms.Web.Alert(response.IsSuccess, response.Content, function () {
                location.reload();
            });
            Xms.Web.Event.localStorageEvent.trigger('list_ribbonbutton_rebind');

            setTimeout(function () {
                location.reload();
            }, 3000);
        }, null, function () {
            $('#ShowArea').val($('#ShowArea').next().children('option:selected').val());
        });
        $(".modal").draggable({
            handle: ".modal-header",
            cursor: 'move',
            refreshPositions: false
        });

        $('#Icon').xmsAutoComplete({
            datas: bsicons,
            itemClass: 'iconsarr',
            itemTmpl: '<li class="{{itemClass}} {{itemOther}}" value="{{itemValue}}">{{itemTitle}}</li>',
            dataFilter: function (data) {
                var res = [];
                $.each(data, function (i, n) {
                    var obj = {
                        value: n,
                        other: n,
                    }
                    res.push(obj);
                });
                return res;
            }
        });
        var btnCssArr = [];
        $.each(btnColorArr, function (i, n) {
            $.each(btnSizeArr, function (ii,nn) {
                btnCssArr.push('btn ' + n + ' ' + nn);
            });
        });
        $('#CssClass').xmsAutoComplete({
            datas: btnCssArr,
            itemClass: 'btnCssarr',
            itemTmpl: '<li class="{{itemClass}}" value="{{itemValue}}"><div class="{{itemOther}}">按钮</div></li>',
            dataFilter: function (data) {
                var res = [];
                $.each(data, function (i, n) {
                    var obj = {
                        value: n,
                        other: n,
                    }
                    res.push(obj);
                });
                return res;
            }
        });

        /*点击确定时，遍历所有的 拼接字符串*/
        $("#btnFormStatusConfirm").click(function () {
            var StatusJson = {};
            //第一个函数传入父节点 遍历出子节点的数据返回对象
            StatusJson.FormStateRules = setFormStatusBodyInfo($("#formStatusBody"));
            StatusJson.ValueRules = setAttributeBody($("#attributevalueBody"));
            var statusJsonStr = JSON.stringify(StatusJson);
            $("#CommandRules").val(statusJsonStr);
            console.log(statusJsonStr);
            $('#ruleModal').modal('hide');
        });

        /* 按钮显示规则/按字段值添加*/
        $("#addAttributevalue").click(function () {
            var newAttributevalueOperationBody = $("#attributevalueOperationBody").clone();
            newAttributevalueOperationBody.find(".col-sm-1>button").css("display", "inline");/*获取到newAttributevalueOperationBody里面的button元素 设置其样式*/
            var idStr = Xms.Utility.Guid.NewGuid().ToString('N');//生成一个guid
            newAttributevalueOperationBody.prop("id", "attributevalueOperationBody" + idStr); /*修改id */

            newAttributevalueOperationBody.find("#attributevalue_select").attr("id", "attributevalue_select" + idStr).val('');
            newAttributevalueOperationBody.find("#attributevalue_text1").attr("id", "attributevalue_text1" + idStr).val('');
            $("#attributevalueBody").append(newAttributevalueOperationBody);
        });

        /*#按属性进行清空*/
        $("#removeAttributevalue").click(function () {
            removeAll($("#attributevalueBody"));
        });

        /*$('#jslibrary_text').lookup({
            disabled: true,
            dialog: function () {
                Xms.Web.OpenDialog('/customize/webresource/dialog?singlemode=true&inputid=jslibrary_text', 'selectRecordCallback');
            }
            , clear: function () {
                $('#jslibrary_text').val('');
                $('#jslibrary').val('');
            }
        });*/
        Xms.Web.GetJson('/api/webresource/list?getall=true', null, function(res){
            if(!res.Content) return;
            var _selector = $('#jslibrary');
            $(res.Content).each(function(i, n){
                _selector.append('<option value="ws:'+n.webresourceid+'">'+n.name+'</option>');
            });
        });
        loadAttributes();
    });

    function setBtnStyle(_this) {
        var $this = $(_this);
        $('#Label').val($this.get(0).innerText.trim());
        $('#CssClass').val($this.prop('class'));
        $('#Icon').val($this.find('span:first').prop('class'));
        $('#ShowArea').val($('#ShowArea').next().children('option:selected').val());
    }
    /*根据attribute选择的数据 设置对象 返回*/
    function setAttributeBody(_$attributevalueBody) {
        var attributeSatusJson = {};
        attributeSatusJson.Values = [];
        var childAttributeStatusBodys = _$attributevalueBody.children();
        childAttributeStatusBodys.each(function (index, obj) {
            var jsonAttribute = {};
            var attributeSlectTextValue = Xms.Web.SelectedValue($(this).find("select"));
            if (!attributeSlectTextValue) return true;
            jsonAttribute.Field = attributeSlectTextValue;
            var attributeValue = $(this).find("input[type=text]").val();
            jsonAttribute.Value = attributeValue;
            attributeSatusJson.Values.push(jsonAttribute);//加入到对象数组中
        });
        if (attributeSatusJson.Values && attributeSatusJson.Values.length > 0) {
            attributeSatusJson.visibled = $('input[name="attributevalue_visibled"]:checked').val();
            attributeSatusJson.enabled = $('input[name="attributevalue_enabled"]:checked').val();
        }
        else {
            attributeSatusJson = null;
        }
        return attributeSatusJson;
    }

    /*遍历formStatusBody$对象    返回对应格式的对象*/
    function setFormStatusBodyInfo(_$formStatusBody) {
        var formSatusJson = {};
        formSatusJson.States = [];
        var childFormStatusBodys = _$formStatusBody.find("input[type=checkbox]:checked"); //得到每一个formStatusBody下的所有行
        childFormStatusBodys.each(function (index, obj) {
            formSatusJson.States.push($(obj).val());
        });
        if (formSatusJson.States && formSatusJson.States.length > 0) {
            formSatusJson.visibled = $('input[name="formstate_visibled"]:checked').val();
            formSatusJson.enabled = $('input[name="formstate_enabled"]:checked').val();
        }
        else {
            formSatusJson = null;
        }
        return formSatusJson;
    }
    /*根据父节点循环删除子节点*/
    function removeAll(_parentElement) {
        var elementBodyChild = _parentElement.children();
        for (var i = 1; i < elementBodyChild.length; i++) {
            elementBodyChild[i].remove();
        }
    }
    /*按钮显示规则/按表单状态单个删除方法,点击的时候调用这个方法，把元素的父节点传递过来*/
    function deleteLine(_parentElement) {
        _parentElement.remove();
    }

    /*ajax请求实体的数据*/
    function loadEntities() {
        Xms.Schema.GetEntities({getall: true}, function (data) {
            if (!data || data.items.length == 0) return;
            $(data.items).each(function (i, n) {
                $('#entityper_select').append("<option value=\"" + n.name + "\">" + n.localizedname + '</option>');
            });
            //$('#EntityId').val($('#EntitySel').find('option:selected').val());
        });
    }

    /*ajax请求字段数据*/
    function loadAttributes() {
        /*获取到点击进来的实体的 所有的字段*/
        $('#attributevalue_select').find('option:gt(0)').remove();
        Xms.Schema.GetAttributesByEntityId($('#EntityId').val(), function (data) {
            if (!data || data.length == 0) return;
            $(data).each(function (i, n) {
                $('#attributevalue_select').append("<option value=\"" + n.name + "\">" + n.localizedname + '</option>');
            });
            //$('#AttributeId').val($('#AttributeSel').find('option:selected').val());
        });
    }
</script>

</body>
</html>